;; 手动模拟call/cc的行为

(display "开始手动模拟call/cc\n")

;; 定义一个过程，它接受一个过程参数，并调用它
(display "定义my-call前\n")
(define my-call (lambda (proc) 
                  (display "进入my-call\n") 
                  (display "调用proc前\n")
                  (define proc-result (proc (lambda (x) 
                                              (display "进入恒等函数\n")
                                              (display "恒等函数参数: ")
                                              (display x)
                                              (display "\n")
                                              x)))
                  (display "proc返回: ")
                  (display proc-result)
                  (display "\n")
                  proc-result))

(display "定义my-call后\n")

;; 使用这个过程
(display "调用my-call前\n")
(define result (my-call (lambda (k) 
                          (display "进入lambda\n")
                          (display "调用k前\n")
                          (define k-result (k 42))
                          (display "调用k后\n")
                          (display "k返回: ")
                          (display k-result)
                          (display "\n")
                          k-result)))

(display "结果: ")
(display result)
(display "\n")
(display "测试结束\n")